package com.Dao;

import java.sql.SQLException;
import java.util.List;


import com.entity.Studios;

public class StudiosDao extends BaseDao{
    /**
     * 查询所有数据
     */
    public List<Studios> queryStudios() throws SQLException {


            String sql = "select * from studios ";
            return findList(Studios.class, sql);

    }

    /**
     * 根据编号查询单条数据
     * @param id
     * @return
     */
    public Studios queryStudios(int id) throws SQLException {

        String sql = "select * from studios where id=?";
        Object[] params = {id};
        return findBean(Studios.class, sql, params);

    }

    /**
     * 根据实体类数据更新用户
     * @param studios1
     * @return
     */
    public int updateStudios(Studios studios1) {
        String sql = "update studios set HallName=?, CinemaName=?,CinemaAddress=?,MovieTitle=?,StartTime =?," +
                "Price =?,Surplus =?,where id=?";
        Object[] params = {studios1.getHallName(),studios1.getCinemaName()
                ,studios1.getCinemaAddress(),studios1.getMovieTitle(),studios1.getStartTime()
                ,studios1.getPrice(),studios1.getSurplus(),studios1.getId()};
        try {
            return queryRunner.update(sql, params);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
//
//    /**
//     * 根据id删除一条数据
//     * @param id
//     * @return
//     */
//    public int deleteStudios(int id) {
//        String sql = "delete from studios where id=?";
//        Object[] params = {id};
//        return update(sql, params);
//    }
//
//    /**
//     * 根据用户对象增加一条数据
//     * @param studios1
//     * @return
//     */
//    public int insertStudios(Studios studios1) {
//         String sql = "insert into studios where values=(null,?,?,?,?,?,?)";
//        Object[] params = {studios1.getHallName(),studios1.getCinemaName()
//                ,studios1.getCinemaAddress(),studios1.getMovieTitle(),studios1.getStartTime()
//                ,studios1.getPrice(),studios1.getSurplus()};
//        return update(sql, params);
//    }

}
